﻿using System;
using System.Data;
using System.Windows.Forms;

namespace WindowsApplication2._750_数据库.小功能
{
    public partial class Form111 : Form
    {
        public Form111()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string sql = "";

            string datasource = "localhost";
            string uid = "root";
            string pwd = "";

            string strCon = "server=" + datasource + ";user id=" + uid + "; pooling=false;charset=latin1; password=" + pwd + "; Allow Zero Datetime=True";
            MysqlHelper.strConnString = strCon;
            DataTable dt = get_tushu();
            foreach (DataRow dr in dt.Rows)
            {
                sql += "update xinshenghu.timesheet set gongzuoneirong='" + dr["gongzuoneirong"] + "' where id=" + dr["id"] + ";";
            }

            datasource = "xinshenghu.gotoftp2.com";
            uid = "xinshenghu";
            pwd = "198303";

            strCon = "server=" + datasource + ";user id=" + uid + "; pooling=false;charset=gbk; password=" + pwd + "; Allow Zero Datetime=True";
            MysqlHelper.strConnString = strCon;
            MysqlHelper.ExecuteNonQuery(sql);

            MessageBox.Show("ok");
        }

        private DataTable get_tushu()
        {
            string sql = "select * from xinshenghu.timesheet order by id";
            DataTable dt = MysqlHelper.GetDataTable(sql);
            dt.Columns.Add("orderid");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["orderid"] = i + 1;
            }
            return dt;
        }
    }
}